package com.bo.mybatis.mapper;


import com.bo.mybatis.model.StudentInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentInfoMapper {
    // 如果想要直接查询所有学生,就不能这样写
    // 如:mysql中的命名规范:class_id 但是 java的命名规范:classId
    // 这样就会导致查询不到class_id,使得classId为null,因此有以下解决方法:
    // 1.起别名(class_id as classId)
    String selectStudent = "select id,name,chinese,math,english,sum," +
            "class_id as classId,School_id as schoolId from student";
    @Select(selectStudent)
    List<StudentInfo> getList();
    // 2.使用@Results注解
    @Results(id = "result",value = {
            @Result(column = "class_id",property = "classId"),
            @Result(column = "School_id",property = "schoolId")
    })
    @Select("select * from student")
    List<StudentInfo> getList2();
    @ResultMap(value = "result")
    @Select("select * from student")
    List<StudentInfo> getList3();
    @Select("select * from student")
    List<StudentInfo> getList4();
}
